package javaVersion.learn.batchProcess;

import javaVersion.pojo.NewPerson;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;

/**
 * @author Wincoma
 * @date 2020/7/14 16:45
 * @description
 */
public class Pro2_ReadCsvFile {
    public static void main(String[] args) throws Exception {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        String filePath = "I:\\newProject\\myFlink\\src\\main\\resources\\my.csv";
        csvFile(env,filePath);

    }

    public static void csvFile(ExecutionEnvironment env,String filePath) throws Exception {

        DataSource<NewPerson> csvInput = env.readCsvFile(filePath)
                .fieldDelimiter(",")
                .ignoreFirstLine()
                .includeFields(true, false, true)
                .pojoType(NewPerson.class, "name", "address");
        csvInput.print();


    }
}
